import Request from "../utils/Request.js";

const Api = {
    //用户操作
    login: "/api/auth/login",//登录
    register: "/api/auth/register",//注册
    askCode: "/api/auth/ask-code",//获取验证码
    //文章操作
    uploadImage: "/api/v1/upload_image",
    userAction: "/api/v1/user_action"
}

//上传封面
const uploadImage = async (file, createThumbnail = false) => {
    let result = await Request({
        url: Api.uploadImage,
        params: {
            file,
            createThumbnail
        },
    })
    if (!result) {
        return;
    }
    return result.data;
}

const doUserAction = async (config, callback) => {
    let result = await Request({
        url: Api.userAction,
        params: config,
        showLoading: true,
    })
    if (!result) {
        return;
    }
    callback()
}

export {
    Api,
    uploadImage,
    doUserAction
}